<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>首页</title>
    <link rel="stylesheet" href="/asset/layui/css/layui.css">
    <link rel="stylesheet" href="/asset/css/index.css">
    <link rel="stylesheet" href="/asset/plugin/formSelects/dist/formSelects-v4.css">
    <script type="text/javascript" src="/asset/js/jquery-3.3.1.min.js"></script>
	<script src="/asset/layui/layui.js"></script>
</head>
<body>

	<div class="alert_bigbox">
		
		<form class="layui-form">
		    <input type="hidden" name="devicesId" value="${devices.devicesId}">
		    <div class="layui-form-item">
			    <label class="layui-form-label">到期时间</label>
			    <div class="layui-input-inline layui-form-mid layui-word-aux">
			         <#if devices.expireDate??>
			         	<span class=" layui-badge layui-bg-red">${devices.expireDate?string('yyyy-MM-dd')}</span>
			         <#else>
			         	永久
			         </#if>
			    </div>
			</div>
		    <div class="layui-form-item">
			    <label class="layui-form-label">续签时间</label>
			    <div class="layui-input-inline ">
			         <input type="text" class="layui-input" name="renewTime" id="renewTime" placeholder="请选择续签时间">
			    </div>
			</div>
			<div class="layui-form-item">
              <label class="layui-form-label"></label>
              <button  class="layui-btn" lay-filter="add" lay-submit="">确认续签</button>
          </div>
		</form>
	</div>
<script>
    layui.use(['form','laydate'], function(){
        
        var $ = layui.jquery
            ,form = layui.form
            ,layer= layui.layer
            ,laydate = layui.laydate;
        
        laydate.render({
		    elem: '#renewTime'
		    ,format: 'yyyy-MM-dd'
		    ,min: '<#if devices.expireDate??>${devices.expireDate?string('yyyy-MM-dd')}</#if>'
		  });    
        
        form.on('submit(add)', function(data){
        		
        		var field = data.field ;
        		
        		$.ajax({
      			type:"POST", 
      			url:"/admin/devices/renew/post.htm",
      			data:field,
      			success:function(result) {
		      
		      		if(result.code=='1'){
		      			layer.alert("续签成功", {icon: 6},function () {
			                // 获得frame索引
			                 window.parent.location.reload();
			                var index = parent.layer.getFrameIndex(window.name);
			                //关闭当前frame
			                parent.layer.close(index);
			            });
		      		}else{
		      		 	layer.msg(result.msg);
		      		}
		      
		    	 	} 
		    }); 
            
            
            return false;
          });
        
         
    });





</script>
</body>
</html>